import '../utils/date_utils.dart';

/// 字典数据-请求
class DictDataReq {
  final String code, val, childCode;

  const DictDataReq({
    required this.code,
    this.val = '',
    this.childCode = '',
  });

  Map<String, dynamic> toMap() => {
        'val': val,
        'childCode': childCode,
      };
}

/// 字典数据-响应
class DictDataRes {
  final String label, val, code, cssClass, listClass, remark;
  final int def, seq, status;
  final DateTime? createdAt;

  const DictDataRes({
    required this.code,
    required this.label,
    required this.val,
    required this.cssClass,
    required this.listClass,
    required this.remark,
    required this.def,
    required this.seq,
    required this.status,
    this.createdAt,
  });

  factory DictDataRes.fromMap(final Map<String, dynamic> map) => DictDataRes(
        code: map['code'] ?? '',
        label: map['label'] ?? '',
        val: map['val'] ?? '',
        cssClass: map['cssClass'] ?? '',
        listClass: map['listClass'] ?? '',
        remark: map['remark'] ?? '',
        def: map['def'] ?? 0,
        seq: map['seq'] ?? 0,
        status: map['status'] ?? 0,
        createdAt: dateUtils.parse('yyyy-MM-dd HH:mm:ss', map['createdAt']),
      );
}
